package com.example.jussi.intentservicedemo;

import android.app.IntentService;
import android.content.Intent;
import android.util.Log;

/**
 * IntentService = ThreadHandler + Service
 * 完成耗时任务后会自己销毁
 * Created by admin on 2018/12/2.
 * 记得一定要注册
 */

public class MyIntentService extends IntentService {

    public MyIntentService() {
        super("");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("--------------------", "Service Start");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        int i = 100;
        while (i>0){
            Log.d("----------", i+"");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i--;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d("---------------------", "Service Stop");
    }
}
